<template>
  <BasicModal 
    v-bind="$attrs" 
    @register="registerModal" 
    title="选择预览类型" 
    @ok="handleSubmit"
    :canFullscreen="false"
    width="600px" 
  >
    <BasicForm @register="registerForm" />
  </BasicModal>
  
</template>
<script lang="ts" setup>
import { ref, computed, unref, reactive } from 'vue';
import { Button } from 'ant-design-vue'
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicForm, useForm, FormSchema } from '/@/components/Form/index';
import { useMessage } from '/@/hooks/web/useMessage';
const { createMessage } = useMessage();
const emit = defineEmits(['register', 'success']);
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
  
});

const formSchema: FormSchema[] = [
  {
    label: '框架',
    field: 'frame',
    component: 'Select',
    defaultValue: "vben",
    required: true,
    componentProps: () => {
      return {
        options: [
          { lable: 'vben', value: 'vben' }
        ]
      };
    },
  }
];
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
  labelWidth: 100,
  schemas: formSchema,
  showActionButtonGroup: false,
});

async function handleSubmit() {
  try {
    await validate();
    closeModal();

    emit('success');
  } finally {
    setModalProps({ confirmLoading: false });
  }
}
</script>
